<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <script src="./js/earthsdk.js"></script>
    <!-- 自定义Css样式 -->
    <link rel="stylesheet" href="./css/example1.css" />
    <script src="./js/Colorpicker.js"></script>

    <title>feature等值条件显隐控制</title>
    <style>
        html,
        body,
        #app {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
    </style>
</head>

<body>
    <div id="app"></div>
    <div id="panel">
        <button onclick="setFeatureVisable()">屋顶隐藏</button>
        <button onclick="resetFeatureStyle()">屋顶显示</button>
    </div>
    <script>
        /** ---------------------------------地球创建------------------------------------**/

        // Vue中引入方式：import { ESObjectsManager } from 'esobjs-xe2-plugin/dist-node/esobjs-xe2-plugin-main';

        const { ESObjectsManager, ES3DTileset } = XE2["esobjs-xe2-plugin-main"];

        const { PickedInfo } = XE2["xe2-base-objects"];
        // 对象管理器
        const objm = new ESObjectsManager();
        window.g_objm = objm;

        // 创建Cesium视口
        const viewer = objm.createCesiumViewer({
            domid: document.getElementById("app"),
        });
        // 监听视口状态
        viewer.statusChanged.don((status) => {
            if (status == "Created") {
                viewer.flyIn([116.39193482449402, 39.906399291545384, 54.28013086155778], [324.55877082508925, -36.824132668310035, 359.999935971016], 2);
            }
        });

        // 通过json创建一个影像图层
        const imageryLayer = objm.createSceneObjectFromJson({
            id: "9812a65f-0de0-4f7b-b234-809c0c2fb8ef",
            type: "ESImageryLayer",
            url: "https://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
        });

        // 创建ES3DTileset对象
        const es3DTileset = objm.createSceneObject(ES3DTileset);
        // url服务地址
        es3DTileset.url = "https://www.pipeser.com/cesiumlab/jgYgbe3y/tileset.json";
        // 加载完成
        es3DTileset.tilesetReady.don((tileset) => {
            setFeatureVisable()
        })
        window.es3DTileset = es3DTileset;

        // 屋顶隐藏
        function setFeatureVisable() {
            es3DTileset.setFeatureVisable(
                "id", [
                {
                    value: "6949fe393e9a4d4db7fe71339c61513800022318",
                    visable: false,
                },
            ]
            );
        };

        // 恢复原始
        function resetFeatureStyle() {
            es3DTileset.resetFeatureStyle();
        }

    </script>

    <!-- 切换UE和Cesium引擎的组件（Vue） -->
    <div id="root">
        <switch-engine :objm="objm"></switch-engine>
    </div>
    <!-- Vue文件 -->
    <script src="./js/vue.global.js"></script>
    <!-- 切换UE和Cesium的组件 -->
    <script src="./js/switchEngineCom.js"></script>
</body>

</html>